Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: webxdc notify & privacy preserving selfAddr #90

Merged
merged 27 commits into from
Nov 26, 2024
Merged

Conversation

r10s
Copy link
Contributor

@r10s r10s commented Nov 19, 2024

this PR is the documentation part of the M2/M3 tasks from https://github.com/orgs/deltachat/projects/77 , currently about notify / deeplinks (click system events)

closes #89

@r10s r10s changed the title docs: webxdc notify & deeplink docs: webxdc notify Nov 19, 2024
@r10s r10s marked this pull request as ready for review November 19, 2024 17:18
src-docs/spec/sendUpdate.md Outdated Show resolved Hide resolved
@r10s r10s changed the title docs: webxdc notify docs: webxdc notify & system-events Nov 20, 2024
@@ -17,6 +17,9 @@ Send an update to all peers.
Do not add linebreaks; implementations will truncate the text at about 50 characters or less.
If there are series of info messages, older ones may be dropped.
use this option sparingly to not spam the chat.
- `update.notify`: optional array of [user addresses](./selfAddr_and_selfName.md)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to increase the usefulness of this API, would be nice if dev could pass update.notify=["all"] to avoid having to collect user IDs before being able to notify, for example a calendar app, it is good that events cause notification without the need of every user opening the app first

@@ -0,0 +1,42 @@
# setSystemListener
Copy link
Contributor

@adbenitez adbenitez Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meta: this whole API looks a bit unnecessary, the common way to handle deep-linking in the web, and what most web apps support and web devs are used to is #hash in the URL which the web already provides APIs for accessing and parsing, and some frameworks like React with URL routing system would support and work out of the box,

on sending the update with deep-link the dev could set a update.link="#fragment" then all what the webview needs to do is to set the url to baseUrl+"#fragment" no yet another event listener, state and API to learn

this would be much easier to implement for developers, for example, to jump to a section in the HTML document when clicking the notification would require ZERO Javascript for the developer as the feature to jump to section/element ID via hash works out of the box in the web

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you inform the app of multiple clicks (i.e. on desktop where a webxdc app runs concurrently)?
Also, if you can provide some concrete APIs for #hash in a web app, that would be nice.

Copy link
Contributor

@adbenitez adbenitez Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you inform the app of multiple clicks (i.e. on desktop where a webxdc app runs concurrently)?

this works the same as it is today in web APIs, you just open the link, if the app is already in that subpage/link nothing needs to be done

Also, if you can provide some concrete APIs for #hash in a web app, that would be nice.

it is used already by apps like the public bot index, see url: https://deltachat-bot.github.io/public-bots/#/home

in that app there is a single page "#/home" but if an about page etc. is added or a category "games" to a xdc store app, etc. user could then open that link/section directly, also it is not only about fragments, that are relative links and would work for subpages ex. update.link="./scoreboard" to open a dedicated scoreboard page, which is useful for simpler apps that don't use #fragment routing like react et al.

basically real deep-linking, just linking to inside an app

Copy link
Contributor

@adbenitez adbenitez Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that app there is a single page "#/home" but if an about page etc. is added or a category "games" to a xdc store app, etc. user could then open that link/section directly, also it is not only about fragments, that are relative links and would work for subpages ex. update.link="./scoreboard" to open a dedicated scoreboard page, which is useful for simpler apps that don't use #fragment routing like react et al.

Are you saying that the webxdc app should be reloaded on click, but with a different path or fragment?
Is this easy to do on Android (and other platforms)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String) or similar API should be possible on any platform.
Needs testing whether it results in full reload and losing everything if you only change the fragment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you are talking about window.location.hash -- and if a user clicks an info message, then we reset that hash? Would the running web app be able to notice that?

Copy link

@Amzd Amzd Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. On iOS if you just change the hash part of a URL a webview does not reload.

Would the running web app be able to notice [the hash change]?

Yep: https://developer.mozilla.org/en-US/docs/Web/API/Window/hashchange_event

r10s added a commit to deltachat/deltachat-core-rust that referenced this pull request Nov 22, 2024
this PR adds support for the property `update.notify` to notify about
changes in `update.info` or `update.summary`. the property can be set to
an array of addresses [^1]

core emits then the event `IncomingWebxdcNotify`, resulting in all UIs
to display a system notification, maybe even via PUSH.

for using the existing `update.info` and `update.summary`: the message
is no secret and should be visible to all group members as usual, to not
break the UX of having same group messages on all devices of all users -
as known already from the normal messages.

also, that way, there is no question what happens if user have disabled
notifications as the change is presented in the chat as well

doc counterpart at webxdc/website#90

closes #6217 

[^1]: addresses come in either via the payload as currently or as an
explicit sender in the future - this does not affect this PR. same for
translations, see discussions at #6217 and #6097

---------

Co-authored-by: adb <asieldbenitez@gmail.com>
Co-authored-by: l <link2xt@testrun.org>
@hpk42
Copy link
Contributor

hpk42 commented Nov 22, 2024

I removed setSystemEventListener, and added an "update.href" attribute to allow a receiver to directly navigate the webxdc app to this href.

@hpk42
Copy link
Contributor

hpk42 commented Nov 22, 2024

also refined "selfAddr" and "selfName", and added an example using them together with notify.

@hpk42 hpk42 changed the title docs: webxdc notify & system-events docs: webxdc notify & privacy preserving selfAddr Nov 23, 2024
r10s added a commit to deltachat/deltachat-core-rust that referenced this pull request Nov 23, 2024
add `update.href` property option to update objects send via
`Context::send_webxdc_status_update()`.

when set together with `update.info`,
UI can implement the info message as a link that is passed to the webxdc
via `window.location.href`.
for that purpose, UI will read the link back from
`Message::get_webxdc_href()`.

Practically,
this allows e.g. an calendar.xdc
to emits clickable update messages
opening the calendar at the correct date.

closes #6219

documentation at webxdc/website#90
@hpk42 hpk42 changed the base branch from main to next-main November 23, 2024 18:38
@singpolyma
Copy link

The new href idea I understand I think. But what is the notify key for?

@hpk42
Copy link
Contributor

hpk42 commented Nov 25, 2024

The new href idea I understand I think. But what is the notify key for?

notify is for displaying a user-visible notification on the phone of (selected) receiving users .
It's for e.g. the chess-board app: when two people enter a game, then the app will send the user a notification when it's their turn. If they click the notification they go to the app, and can hit start.

…o a dictionary

and introduce a catch-all "*" key.
this commit also fixes the example which is maybe a bit large now
and should rather be a pointer to some actual little pseudo-chat app.

- `update.href`: optional string that can be passed as the navigation
location to the webxdc app.
If specified the string must start with `#` and can not contain any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this restricts it too much and potentially make it hard for single-page apps with hash routers that want to use query part for a dialog while the hash is used for pages

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with some examples it is good enough to avoid confusion or force to always declare the path: index.html#fragment instead of allowing sending #fragment only

- `update.href`: optional string that can be passed as the navigation
location to the webxdc app.
For now, only hash or fragment references are allowed.
Strings must start with `#` and can not contain any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this must start with index.html#, see deltachat/deltachat-ios#2412 (comment)

src-docs/spec/selfAddr_and_selfName.md Outdated Show resolved Hide resolved
src-docs/spec/selfAddr_and_selfName.md Outdated Show resolved Hide resolved
src-docs/spec/selfAddr_and_selfName.md Outdated Show resolved Hide resolved
src-docs/spec/selfAddr_and_selfName.md Outdated Show resolved Hide resolved
src-docs/spec/selfAddr_and_selfName.md Outdated Show resolved Hide resolved

- `update.info`: optional, short, informational message that will be added to the chat,
e.g. "Alice voted" or "Bob scored 123 in MyGame".
Do not add linebreaks; implementations will truncate the text at about 50 characters or less.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw "50 character or less" for info message sounds super restrictive, some users's display name alone (ex. name and lastname) will take up most of that

@hpk42 hpk42 merged commit 5f59743 into next-main Nov 26, 2024
hpk42 pushed a commit that referenced this pull request Dec 3, 2024
Add API for notifications and refined `selfAddr` and based on discussions with r10s, adb, hocuri, link2xt and others.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

document notification/deeplinking/system-event api (M2/M3)
8 participants